class UpperAttrMetaClass(type):
    #__new__是在__init__之前被调用的特殊方法，用来创建对象并返回，
    #而__init__只是将传递的参数赋给对象
    def __new__(cls,class_name,class_parent,class_attr):
        # 遍历属性字典，把不是__开头的属性名称都编程大写
        newAttr = {}
        for name, value in class_attr.items():
            if not name.startswith("__"):
                newAttr[name.upper()] = value
        # 方法1：调用type来创建类
        #return type(class_name, class_parent, newAttr)

        #方法2：复用type.__new__方法
        #return type.__new__(cls,class_name,class_parent,newAttr)

        #方法3：使用super方法
        return super(UpperAttrMetaClass,cls).__new__(cls,class_name,class_parent,newAttr)



class A(object,metaclass=UpperAttrMetaClass):
    mark="帅哥"

print(hasattr(A,"mark"))
print(hasattr(A,"MARK"))

print(A.MARK)


